package com.iseastar.dianxiaosan.home.adapter;

import android.app.Activity;
import android.content.Intent;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.iseastar.dianxiaosan.home.parcel.ParcelWaitActivity;
import com.iseastar.dianxiaosan.model.ParcelWaitBean;
import com.iseastar.dianxiaosan.model.ParcelWaitResultBean;
import com.iseastar.guojiang.app.Intents;
import com.shouhuobao.station.R;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterExt;

/**
 * Created by joker on 2017/6/7.
 */

public class ParcelWaitMainAdapter extends BaseAdapterExt<ParcelWaitResultBean> {

    /**
     * 在线支付数量
     */
    private int onLinePayNum;
    /**
     * 到店支付的数量
     */
    private int cashPayedNum;

    public int getOnLinePayNum() {
        return onLinePayNum;
    }

    public void setOnLinePayNum(int onLinePayNum) {
        this.onLinePayNum = onLinePayNum;
    }

    public int getCashPayedNum() {
        return cashPayedNum;
    }

    public void setCashPayedNum(int cashPayedNum) {
        this.cashPayedNum = cashPayedNum;
    }

    public ParcelWaitMainAdapter(ArrayList<ParcelWaitResultBean> items, Activity context, ViewGroup listView) {
        super(items, context, listView);
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_parcel_waitmain, parent, false);
            holder.expressnameTV = (TextView) convertView.findViewById(R.id.expressnameTV);
            holder.onlinepaynumTV = (TextView) convertView.findViewById(R.id.onlinepaynumTV);
            holder.onlinepaynumRL = (RelativeLayout) convertView.findViewById(R.id.onlinepaynumRL);
            holder.reachshoppayRL = (RelativeLayout) convertView.findViewById(R.id.reachshoppayRL);
            holder.reachshoppayTV = (TextView) convertView.findViewById(R.id.reachshoppayTV);
            holder.tipsTV = (TextView) convertView.findViewById(R.id.tipsTV);
            holder.payBT = (Button) convertView.findViewById(R.id.payBT);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.onlinepaynumTV.setText("用户在线支付" + onLinePayNum + "个");
        holder.reachshoppayTV.setText("用户到店支付" + cashPayedNum + "个");
        final ParcelWaitResultBean resultBean = getItems().get(position);
        //查看在线支付包裹
        holder.onlinepaynumRL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ParcelWaitActivity.class);
                intent.putExtra("bean",resultBean.getPayed());
                context.startActivity(intent);
            }
        });
        //查看到店支付包裹
        holder.reachshoppayRL.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ParcelWaitActivity.class);
                intent.putExtra("bean",resultBean.getUnPayed());
                context.startActivity(intent);
            }
        });
        //点击结算
        holder.payBT.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        return convertView;
    }

    private static class ViewHolder {
        TextView expressnameTV;//快递名称
        TextView onlinepaynumTV;//在线支付个数
        RelativeLayout onlinepaynumRL;//在线支付布局
        RelativeLayout reachshoppayRL;//到店支付布局
        TextView reachshoppayTV;//到店支付个数
        TextView tipsTV;//提示
        Button payBT;//结算按钮
    }
}
